<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<script type="text/javascript" charset="UTF-8" src="../js/jquery-ui-1.7.2.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/jquery-ui-1.7.2.custom.css"/>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%> 
<%--貨到付款出貨前可以修改地址，其他付款方式只有付款前可以修改地址 --%>
<c-rt:set var="canChgAddr" value="N"/>
<c:choose>
	<c:when test="${order.paymentTp=='30' || order.paymentTp=='60'}">
		<c:if test="${order.orderSt=='00'}">
			<c-rt:set var="canChgAddr" value="Y"/>
		</c:if>
		<c:if test="${order.orderSt=='20' && order.sync=='false' }">
			<c-rt:set var="canChgAddr" value="Y"/>
		</c:if>
	</c:when>
	<c:otherwise>
		<c:if test="${order.paymentSt=='00' && order.orderSt == '10'}">	
			<c-rt:set var="canChgAddr" value="Y"/>
		</c:if>					          
	</c:otherwise> 
</c:choose>

<script type="text/javascript">

$().ready(function(){
	$("#contactNameTip").hide();
	$("#mobileTip").hide();
	$("#storeAreaTip").hide();
	$("#storeImageTip").hide();
	$("#showDaphne").hide();
	
	$("#storeArea").children().each(function(){
		var storeAreaInit=$("#storeAreaInit").val();
	    if ($(this).text()==storeAreaInit){
	        $(this).attr("selected","true"); //或是給selected也可
	        storeAreaSelected(storeAreaInit);
	    }
	});
	
	 $("#storeArea").change(function() {
		    $("#imagePreview").html("<img src='/images/daphne/000.gif'>");
			$("#pickStore").html("");
	        var storeArea = $("option:selected", this).val();
			$.post("<c-rt:url value="/dpn/findDaphnes.do"/>",{dpnStoreArea:storeArea},callback,"json");
			function callback(actionResult){
				if(actionResult!=null){
					    var arr_text = actionResult.split("$");										
					var options = '<option value="">请选择</option>';
					 for(i=0;i<arr_text.length;i++)
					 {
						 v=arr_text[i].split(",");
						options += '<option value="' + v[0] + '">' + v[1] + '</option>';
					}
					$("#storeImage").html(options);
					$('#storeImage option:first').attr('selected', 'selected');
				}	
			}
			if($("#storeArea").find('option:selected').text()=="请选择"){
				var options = '<option value="">请选择</option>';
				$("#storeImage").html(options);
			}
			
	   });	
	   
	//去除字串左邊的空白虛格
		function ltrim(instr){
		return instr.replace(/^[\s]*/gi,"");
		}

		//去除字串右邊的空白虛格
		function rtrim(instr){
		return instr.replace(/[\s]*$/gi,"");
		}

		//去除字串前後的空白虛格
		function trim(instr){
		instr = ltrim(instr);
		instr = rtrim(instr);
		return instr;
		}
		function storeAreaSelected(storeAreaInit){
			 var storeArea = storeAreaInit;
			 var storeId =$("#storeId").val();
			 $.post("<c-rt:url value="/dpn/findDaphnes.do"/>",{dpnStoreArea:storeArea},callback,"json");
				function callback(actionResult){
					if(actionResult!=null){
					    var arr_text = actionResult.split("$");										
						var options = '<option value="">请选择</option>';
						 for(i=0;i<arr_text.length;i++)
						 {
							 v=arr_text[i].split(",");
									if(storeId == v[0]){
										options += '<option value="' + v[0] + '" selected="selected">' + v[1] + '</option>';
									}else{
										options += '<option value="' + v[0] + '">' + v[1] + '</option>';	
									}	
								
						}
						$("#storeImage").html(options);
						if(storeId == ""){
							$('#storeImage option:first').attr('selected', 'selected');
						}else{
							$("#imagePreview").html(storeId ? "<img src='/images/daphne/" + storeId + ".jpg'>" : "<img src='/images/daphne/000.gif'>");
							$("#pickStore").html("上海市，"+$("#storeArea").find('option:selected').text()+"，"+$("#storeImage").find('option:selected').text());
							$("#receiverAddr").val($("#storeImage").find('option:selected').text());
							$("#receiverArea").val($("#storeArea").find('option:selected').text());
						}
					}	
				}
		}

	 $("#storeImage").change(function() {
		var tmpstoreArea=$("#storeArea").find('option:selected').text();
		 var storeId = $("option:selected", this).val();
		$("#imagePreview").html(storeId ? "<img src='/images/daphne/" + storeId + ".jpg'>" : "<img src='/images/daphne/000.gif'>");
		if($("option:selected", this).text()=="请选择"){
			$("#pickStore").html("未选取");
			$("#receiverAddr").val("");
		}else{
			$("#pickStore").html("上海市，"+tmpstoreArea+"，"+$("option:selected", this).text());
			$("#receiverAddr").val($("option:selected", this).text());
		}
		$("#receiverArea").val(tmpstoreArea);
		$("#storeId").val(storeId);
	 });	
	 	
	 if($("#receiverAddr").val()!='' && $("#receiverAddr").val()!='(请选择门市地址)'){
			$("#receiverAddr").val($("#storeImage").find('option:selected').text());
			$("#receiverArea").val($("#storeArea").find('option:selected').text());
	  }
		
	  
	  if(${order.paymentTp} == '50' && ${order.orderSt} =='10'){
		$("#showDaphne").show();
	  }
		//发票信息
		//$("#invotype02").attr("checked",true); 
		//		$("#invoTitle").show();
		$('#invotype01').click(function(){
			$("#invoTitle").val("");
			$("#invoTitle").hide();
			$("#invoiceTip").hide();
		});
		$('#invotype02').click(function(){
			$("#invoTitle").show();
		});
	
	$("#go_next").click(function() {
		$("#contactNameTip").hide();
		$("#mobileTip").hide();
		$("#storeAreaTip").hide();
		$("#storeImageTip").hide();
		if($("#receiverName").val()==""){
			$("#contactNameTip").show();
			return false;
		}	
		if($("#mobile").val()==""){
			$("#mobileTip").show();
			return false;
		}
		if($("#invoTitle").val().length+chineseCount($("#invoTitle").val())>40){
    		alert("请使用 中文20个字以内 或 英文40个字以内");
         	return false;
	    }
		if ($('#invotype02').is(":checked") == true && trim($("#invoTitle").val())=="" ){
			$("#invoiceTip").show();
			return false;
		}
		<c-rt:if test="${canChgAddr=='Y'}">	
		if($("#storeArea").find('option:selected').text()=="请选择"){
			$("#storeAreaTip").show();
			return false;
		}
		</c-rt:if>
		/*if($("#storeImage").find('option:selected').text()=="请选择"){
			$("#storeImageTip").show();
			return false;
		}*/
			$("#modAddresDaphneForm").submit();
	});
});
function chineseCount(word){
    var length=0;
    for(var cc=0;cc<word.length;cc++){
       var c = word.charCodeAt(cc);
      if (!(c>=32&&c<=126)) length++;
    }
    return length;
}
</script>

<h1>订单管理</h1>
<div class="f-link"><a href="view.do?orderId=${order.orderId}">回订单查询页</a></div><br><br>
<form action="updateReceiver.do" name="modAddresDaphneForm" id="modAddresDaphneForm" method="post">
<input type="hidden" name="orderId" value="${order.orderId}"/>
<input type="hidden" id="receiverProvince" name="receiverProvince" value="上海"/>
<input type="hidden" id="receiverCity" name="receiverCity" value="上海市"/>
<input type="hidden" id="receiverArea" name="receiverArea" value=""/>
<input type="hidden" id="receiverZip" name="receiverZip" value=""/>
<input type="hidden" id="receiverAddr" name="receiverAddr" value=""/>
<input type="hidden" id="storeId" name="storeId" value="${order.storeId}"/>
<input type="hidden" id="storeAreaInit" name="storeAreaInit" value="${storeAreaInit}"/>
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="tb-data">
	<tr>
   		<td height="30" align=left width="15%"></td>
    	<td align=left  class="bg-yl" width="35%">当前资料</td>
    	<td align=left width="15%"></td>
    	<th align=left>修订资料</th>
  	</tr>
	<tr>
   		<td height="30" align="left"  class="bg-yl">订单编号：</td>
    	<td align=left>${order.orderId}</td>
    	<th align=left>订单编号：</th>
    	<td align=left>${order.orderId}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">会员编号：</td>
    	<td align=left><a href='../member/view.do?memberId=${order.memberId}'>${order.memberId}</a></td>
    	<th align=left>会员编号：</th>
    	<td align=left><a href='../member/view.do?memberId=${order.memberId}'>${order.memberId}</a></td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">订购人：</td>
    	<td align=left>${order.memberName}</td>
    	<th align=left>订购人：</th>
    	<td align=left>${order.memberName}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">订单状态：</td>
    	<td align=left>${orderStMenu.options[order.orderSt].name}</td>
    	<th align=left>订单状态：</th>
    	<td align=left>${orderStMenu.options[order.orderSt].name}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">订购日期：</td>
    	<td align=left><fmt:formatDate pattern="yyyy/MM/dd HH:mm:ss" value="${order.orderDt}" /></td>
    	<th align=left>订购日期：</th>
    	<td align=left><fmt:formatDate pattern="yyyy/MM/dd HH:mm:ss" value="${order.orderDt}" /></td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">支付方式：</td>
    	<td align=left>${paymentTpMenu.options[order.paymentTp].name}</td>
    	<th align=left>支付方式：</th>
    	<td align=left>${paymentTpMenu.options[order.paymentTp].name}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">付款状态：</td>
    	<td align=left>${paymentStMenu.options[order.paymentSt].name}</td>
    	<th align=left>付款状态：</th>
    	<td align=left>${paymentStMenu.options[order.paymentSt].name}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">订单来源：</td>
    	<td align=left>${order.channel}</td>
    	<th align=left>订单来源：</th>
    	<td align=left>${order.channel}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">网站：</td>
    	<td align=left>${domainSrc.options[order.domainSrc].name}</td>
    	<th align=left>网站：</th>
    	<td align=left>${domainSrc.options[order.domainSrc].name}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">付款期限：</td>
    	<td align=left>
	    	<c-rt:if test="${order.paymentTp!='30'}">
		    <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.deadline}" />
		    </c-rt:if>
	    </td>
    	<th align=left>付款期限：</th>
    	<td align=left>
    		<c-rt:if test="${order.paymentTp!='30'}">
		    <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.deadline}" />
		    </c-rt:if>
    	</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">收件人：</td>
    	<td align=left>${order.receiverName}</td>
    	<th align=left>收件人：</th>
    	<td align=left>
    	<input type="text"  class="txt-gy" name="receiverName" id="receiverName" value="${order.receiverName}" maxlength="20" size="16"/>
    	<span id="contactNameTip" class="msg rn" style="margin-left:4.3em;*margin-left:4.8em; _margin-left:2.5em; "><font color="#ff3300">请填写姓名</font> </span>  
    	</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">行动：</td>
    	<td align=left>${order.receiverMobile}</td>
    	<th align=left>行动：</th>
    	<td align=left>
    	<input type="text" name="mobile" id="mobile"  value="${order.receiverMobile}" size="18" maxlength="11"/>
    	<span id="mobileTip" class="msg rn" style="margin-left:5.6em;*margin-left:5.9em;_margin-left:2.9em; "><font color="#ff3300">请填写手机号码</font> </span>
    	</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">固定：</td>
    	<td align=left>${order.receiverPhoneArea}-${order.receiverPhone}-${order.receiverExt}</td>
    	<th align=left>固定：</th>
    	<td align=left>
    		<span>
            	<input type="text" name="receiverPhoneArea" id="receiverPhoneArea" value="${order.receiverPhoneArea}" size="5" maxlength="4"/>-
	    		<input type="text" name="receiverPhone" id="receiverPhone" value="${order.receiverPhone}" size="10" maxlength="10" maxlength="8"/>- 分机
				<input type="text" name="receiverExt" id="receiverExt" value="${order.receiverExt}" size="4" maxlength="8"/>
            </span>
		</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">达芙妮取货门市-区域：</td>
    	<td align=left>${order.receiverArea}</td>
    	<th align=left>达芙妮取货门市-区域：</th>
    	<td align=left>
    		<c-rt:if test="${canChgAddr=='Y'}">	
    		<select name="storeArea" id="storeArea">
              <option value="">请选择</option>
              <option value="卢湾区">卢湾区</option>
				<option value="普陀区">普陀区</option>
				<option value="青浦区">青浦区</option>
				<option value="松江区">松江区</option>
				<option value="宝山区">宝山区</option>
				<option value="长宁区">长宁区</option>
				<option value="虹口区">虹口区</option>
				<option value="黄浦区">黄浦区</option>
				<option value="闵行区">闵行区</option>
				<option value="南汇区">南汇区</option>
				<option value="闸北区">闸北区</option>
				<option value="奉贤区">奉贤区</option>
				<option value="金山区">金山区</option>
				<option value="嘉定区">嘉定区</option>
				<option value="杨浦区">杨浦区</option>
				<option value="静安区">静安区</option>
				<option value="浦东新区">浦东新区</option>
				<option value="徐汇区">徐汇区</option>
            </select>
            <span id="storeAreaTip" class="msg rn" style=" margin-left:3.5em;*margin-left:3.75em;_margin-left:1.87em">请选择区域</span><br />
            </c-rt:if>
            <c-rt:if test="${canChgAddr=='N'}">${order.receiverArea}</c-rt:if>	
    	</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">达芙妮取货门市-地址：</td>
    	<td align=left>${order.receiverAddr}</td>
    	<th align=left>达芙妮取货门市-地址：</th>
    	<td align=left>
    		<c-rt:if test="${canChgAddr=='Y'}">	
    		<select name="storeImage" id="storeImage">
              <option value="">请选择</option>
            </select><br/>
           <span id="storeImageTip" class="msg rn" style=" margin-left:3.5em;*margin-left:3.75em;_margin-left:1.87em"> <font color="#ff3300">请选择地址</font> </span>
           </c-rt:if>
           <c-rt:if test="${canChgAddr=='N'}">${order.receiverAddr}</c-rt:if>
    	</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">取货门店：</td>
    	<td align=left>${order.receiverProvince}，${order.receiverCity}，${order.receiverArea}，${order.receiverAddr}，${order.receiverZip}</td>
    	<th align=left>取货门店：</th>
    	<td align=left><span id="pickStore">未选取</span></td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">订单类型：</td>
    	<td align=left>${order.orderType==1?'一般':'SCM'}</td>
    	<th align=left>订单类型：</th>
    	<td align=left>${order.orderType==1?'一般':'SCM'}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">转单供应商：</td>
    	<td align=left>${supplierApply.companyName}</td>
    	<th align=left>转单供应商：</th>
    	<td align=left>${supplierApply.companyName}</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">发票抬头：</td>
    	<td align=left>${order.invoiceTp=='01'?"个人":order.invoiceTitle}</td>
    	<th align=left>发票抬头：</th>
    	<td align=left>
    	<c-rt:if test="${canChgAddr=='Y'}">	
    		<input id="invotype01" name="invotype" type="radio" value="01" ${order.invoiceTp=='01'?" checked='checked'":""}>  <strong>个人</strong>
			<input id="invotype02" name="invotype" type="radio" value="02" ${order.invoiceTp=='02'?" checked='checked'":""}>  <strong>单位</strong> 
			<input size="20" type="text" name="invoTitle" id="invoTitle" value="${order.invoiceTitle}" maxlength="40"/>   <span class="txt-gy">(20个字内)</span>
			<br/><span id="invoiceTip" style="display:none; "><font color="#ff3300">请输入单位抬头</font></span> 
    		</c-rt:if>
    		<c-rt:if test="${canChgAddr=='N'}">${order.invoiceTitle}</c-rt:if>
    	</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">备注：</td>
    	<td align=left>${order.memo}</td>
    	<th align=left>备注：</th>
    	<td align=left>
    		<textarea name=memo cols="50" rows="5">${order.memo}</textarea>
		</td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">最后修改人：</td>
    	<td align=left>${order.modifyUser}</td>
    	<th align=left>最后修改人：</th>
    	<td align=left></td>
  	</tr>
  	<tr>
   		<td height="30" align="left"  class="bg-yl">最后修改时间：</td>
    	<td align=left><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${order.modifyDate}" /></td>
    	<th align=left>最后修改时间：</th>
    	<td align=left></td>
  	</tr>
  <tr>
    <td height="30" colspan="5" align=center>
   <div class="f-link">
	<a id="go_next"  href="javascript:;" >继续</a> 
	</div>
  </b>
</td>
  </tr>
</table>
</form>
<div class="f-link">
	<a href="view.do?orderId=${order.orderId}">回订单查询页</a>
</div>